<?php
namespace app\cms\controller;

use app\common\controller\Front;

class Tags extends Front
{

    public function _initialize()
    {
        parent::_initialize();
    }
    
    public function index()
    {
        return $this->detail('index');
    }
    
    public function _empty($action='')
    {
        //扩展开关
        if(!config('cms.action_name')){
            $this->error(lang('cms_error_params'));
        }
        //允许的操作名
        if(!in_array($action,explode(',',config('cms.action_name')))){
            $this->error(lang('cms_error_params'));
        }
        //默认加载
        return $this->detail($action);
    }
    
    private function detail($action='index')
    {
        $info = [];
        $info['seoTitle']       = cmsSeo(config('cms.tag_title'),$this->site['page']);
        $info['seoKeywords']    = cmsSeo(config('cms.tag_keywords'),$this->site['page']);
        $info['seoDescription'] = cmsSeo(config('cms.tag_description'),$this->site['page']);
        $info['pagePath']       = DcUrl('cms/tags/'.$action,['pageNumber'=>'[PAGE]']);
        $info['pageSize']       = cmsPageSize(config('cms.limit_tags'));
        $info['pageNumber']     = $this->site['page'];
        $info['sortName']       = 'term_order desc,term_count';
        $info['sortOrder']      = 'desc';
        //数据列表
        $item = cmsTagSelect([
            'cache'   => true,
            'status'  => 'normal',
            'action'  => $action,
            'sort'    => $info['sortName'],
            'order'   => $info['sortOrder'],
            'limit'   => $info['pageSize'],
            'page'    => $this->site['page'],
        ]);
        if($item){
            $this->assign($item);
        }
        //变量赋值
        $this->assign($info);
        //加载模板
        return $this->fetch();
    }
}